<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
	<c:set var="emp" value="${sessionScope.user}"/>
	<c:forEach var="ro" items="${emp.roles}">
		<c:forEach var="fu" items="${ro.functionAll}">
			<c:if test="${fu.code=='employee-edit'}">
				<c:set var="empEdit" value="true"/>
			</c:if>
			<c:if test="${fu.code=='employee-logout'}">
				<c:set var="empLogout" value="true"/>
			</c:if>
		</c:forEach>
	</c:forEach>
	
<div class="mailbox row">
	<div class="col-xs-12">
		<div class="box box-solid">
			<div class="box-body">
				<div class="row">
					<div class="col-md-2">
						<!-- --------- 分类导航 start------------- -->
						<div style="margin-top: 15px;">
							<ul class="nav nav-pills nav-stacked">
								<li class="header">员工管理</li>
								<c:forEach var="ro" items="${emp.roles}">
									<c:forEach var="fu" items="${ro.functions['pageMenuItem']}">
										<c:if test="${fu.id==param.parentId }">
											<c:forEach var="child" items="${fu.pageChildren}" varStatus="status">
												<c:if test="${not empty child.menuLog}">
													<c:if test="${empty flag}">
														<c:if test="${child.id==13}">
															<li class="active">
														</c:if>
														<c:if test="${child.id!=13}"> 
															<li>
														</c:if>
																<a href="${initParam.root}/${child.menuEntry}?parentId=10&flag=${child.id}" data-id="${child.id }">
																	<i class="${child.menuLog}"></i>${child.name}
																</a>
															</li>
													</c:if>
													<c:if test="${not empty flag}">
														<c:if test="${flag==13}">
															<li class="active">
														</c:if>
														<c:if test="${flag!=13}">
															<li>
														</c:if>
																<a href="${initParam.root}/${child.menuEntry}?parentId=10&flag=${child.id}" data-id="${child.id }">
																	<i class="${child.menuLog}"></i>${child.name}
																</a>
															</li>
														<c:if test="${flag==16}">
															<li class="active">
														</c:if>
														<c:if test="${flag!=16}">
															<li>
														</c:if>
																<a href="${initParam.root}/${child.menuEntry}?parentId=10&flag=${child.id}" data-id="${child.id }">
																	<i class="${child.menuLog}"></i>${child.name}
																</a>
															</li>
													</c:if>
													
												</c:if>
											</c:forEach>
										</c:if>
										
									</c:forEach>
								</c:forEach>
								<%-- <li class="active"><a href="${initParam.root}/employee"><i class="fa fa-search"></i>查看员工</a></li>
								<li><a href="${initParam.root}/employee-edit"><i class="fa fa-plus-circle"></i>添加员工</a></li>
								<li><a href="#"><i class="fa fa-search-plus"></i>查看所有员工</a></li> --%>
							</ul>
						</div>
						<!-- --------- 分类导航 end------------- -->
					</div>
					<!-- /.col (LEFT) -->
					<div class="col-md-10">
						<div class="row pad">
							<!-- --------- 搜索 start------------- -->
							<!-- <div class="col-sm-12 search-form"> -->
								<form action="" method="get">
									<input type="hidden" name="parentId" value="10">
									<c:if test="${all==true}">
										<div class="col-md-4">
											<label>部门:	</label>
											<select name="deptId">
												<option value="0" selected="selected">全部</option>
												<c:forEach var="dept" items="${allDept}">
													<c:if test="${dept.id!=deptId}">
														<option value="${dept.id}">${dept.name}</option>
													</c:if>
													<c:if test="${dept.id==deptId}">
														<option value="${dept.id}" selected="selected">${dept.name}</option>
													</c:if>
												</c:forEach>
											</select>
										</div>
									</c:if>
									<div class="col-md-4">
										<label>工号:</label><input type="text" name="nr" value="${nrSearch}"/>
									</div>
									<div class="col-md-4">
										<label>姓名:	</label>
										<input name="name" type="text" value="${nameSearch}">
										<button  id="subBtn" type="submit" ref-data="${all}" class="btn btn-sm btn-primary" style="display:inline">
											搜索
										</button>
									</div>
								</form>
							<!--</div>-->
							<script>
								$(function(){
									$("#subBtn").click(function(){
										if($(this).attr("ref-data")=="true"){
											$("form").attr("action","${initParam.root}/employee-allsearch");
										}else{
											$("form").attr("action","${initParam.root}/employee-search");
										}
										$("form").submit();
									});
								})
							</script>
							<!-- --------- 搜索 end------------- -->
						</div>
						<!-- /.row -->
						<!-- 	1.table-responsive放在table的上一级
								2.td里的内容增多
								  才会出现滚动条！ -->
						<div class="table-responsive">
							<!-- --------- 列表 start------------- -->
							<table class="table table-mailbox info">
								<thead>
									<tr>
										<th>工号</th><th>名字</th><th>性别</th><th>部门</th><th>状态</th><th>操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach var="e" items="${employeeList}">
										<tr>
											<td>${e.nr}</td>
											<td><a href="${initParam.root}/employee-info?id=${e.id}&onlyread=1">${e.name}</a></td><td>${e.gender?'男':'女' }</td>
											<td>${e.department.name }</td><td>${e.status==1?'正常':'注销' }</td>
											<td>
												<c:if test="${empEdit==true}">
													<a class="btn btn-primary" style="color:white;" href="${initParam.root}/employee-edit?id=${e.id}&onlyread=0">编辑</a>
												</c:if>
												<c:if test="${empLogout==true}">
													<form style="display:inline" action="${initParam.root}/employee-logout" method="post">
														<input name="id" type="hidden" value="${e.id}"/>
														<button type="submit" class="btn btn-danger">注销</button>
													</form>
												</c:if>
											</td>
										</tr>	
									</c:forEach>
								</tbody>
							</table>
							<!-- --------- 列表 end------------- -->
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /.col (RIGHT) -->
				</div>
				<!-- /.row -->
			</div>
			<!-- /.box-body -->
			<div class="box-footer clearfix">
				<div class="pull-right">
					<c:if test="${all!=true}">
						<small>显示<span>第${pageNum}页</span>共${totalPage}页</small>
						<c:if test="${pageNum>1}">
							<a href="${initParam.root}/employee-search?nr=${nrSearch}&name=${nameSearch}&pageNum=${pageNum-1}" class="btn btn-xs btn-primary">
								<i class="fa fa-caret-left"></i>
							</a>
						</c:if>
						<c:if test="${pageNum<totalPage}">
							<a href="${initParam.root}/employee-search?nr=${nrSearch}&name=${nameSearch}&pageNum=${pageNum+1}" class="btn btn-xs btn-primary">
								<i class="fa fa-caret-right"></i>
							</a>
						</c:if>
					</c:if>
					<c:if test="${all==true}">
						<small>显示<span>第${pageNum}页</span>共${totalPage}页</small>
						<c:if test="${pageNum>1}">
							<a href="${initParam.root}/employee-allsearch?deptId=${deptId}&nr=${nrSearch}&name=${nameSearch}&pageNum=${pageNum-1}" class="btn btn-xs btn-primary">
								<i class="fa fa-caret-left"></i>
							</a>
						</c:if>
						<c:if test="${pageNum<totalPage}">
							<a href="${initParam.root}/employee-allsearch?deptId=${deptId}&nr=${nrSearch}&name=${nameSearch}&pageNum=${pageNum+1}" class="btn btn-xs btn-primary">
								<i class="fa fa-caret-right"></i>
							</a>
						</c:if>
					</c:if>
				</div>
			</div>
			<!-- box-footer -->
		</div>
		<!-- /.box -->
	</div>
	<!-- /.col (MAIN) -->
</div>
<!-- MAILBOX END -->